﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GA.Shared.Interfaces;
using System.Windows;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using System.Windows.Data;

namespace GA.Shared.Objects
{
    public class Hex : LinkedDependencyObject
    {
        /// <summary>
        /// Defines the Id Property.
        /// </summary>
        public static readonly DependencyProperty IdProperty =
            RegisterProperty(
                "Id",
                typeof(int),
                typeof(Hex),
                new PropertyMetadata(-1));

        /// <summary>
        /// Defines the Number Property.
        /// </summary>
        public static readonly DependencyProperty NumberProperty =
            RegisterProperty(
                "Number",
                typeof(int),
                typeof(Hex),
                new PropertyMetadata(-1));

        /// <summary>
        /// Defines the LockedDown Property.
        /// </summary>
        public static readonly DependencyProperty LockedDownProperty =
            RegisterProperty(
                "LockedDownTime",
                typeof(TimeSpan),
                typeof(Hex),
                new PropertyMetadata(null));

        /// <summary>
        /// Defines the OwnerId Property.
        /// </summary>
        public static readonly DependencyProperty OwnerIdProperty =
            RegisterProperty(
                "OwnerId",
                typeof(int?),
                typeof(Hex),
                new PropertyMetadata(null));

        /// <summary>
        /// Defines the Owner Property.
        /// </summary>
        public static readonly DependencyProperty OwnerProperty =
            RegisterProperty(
                "Owner",
                typeof(Agency),
                typeof(Hex),
                new PropertyMetadata(null));

        /// <summary>
        /// Defines the FacilityId Property.
        /// </summary>
        public static readonly DependencyProperty FacilityIdProperty =
            RegisterProperty(
                "FacilityIdProperty",
                typeof(int?),
                typeof(Hex),
                new PropertyMetadata(null));

        /// <summary>
        /// Defines the Facility Property.
        /// </summary>
        public static readonly DependencyProperty FacilityProperty =
            RegisterProperty(
                "Facility",
                typeof(Facility),
                typeof(Hex),
                new PropertyMetadata(null));

        /// <summary>
        /// Defines the IsShielded Property.
        /// </summary>
        public static readonly DependencyProperty IsShieldedProperty =
            RegisterProperty(
                "IsShielded",
                typeof(bool),
                typeof(Hex),
                new PropertyMetadata(false));

        /// <summary>
        /// Defines the ShieldBaseId Property.
        /// </summary>
        public static readonly DependencyProperty ShieldBaseIdProperty =
            RegisterProperty(
                "ShieldBaseId",
                typeof(int?),
                typeof(Hex),
                new PropertyMetadata(null));

        /// <summary>
        /// Defines the ShieldBase Property.
        /// </summary>
        public static readonly DependencyProperty ShieldBaseProperty =
            RegisterProperty(
                "ShieldBase",
                typeof(Hex),
                typeof(Hex),
                new PropertyMetadata(null));

        /// <summary>
        /// Defines the IsBase Property.
        /// </summary>
        public static readonly DependencyProperty IsBaseProperty =
            RegisterProperty(
                "IsBase",
                typeof(bool),
                typeof(Hex),
                new PropertyMetadata(false));

        /// <summary>
        /// Defines the ZoneId Property.
        /// </summary>
        public static readonly DependencyProperty ZoneIdProperty =
            RegisterProperty(
                "ZoneId",
                typeof(int),
                typeof(Hex),
                new PropertyMetadata(-1));

        /// <summary>
        /// Defines the Zone Property.
        /// </summary>
        public static readonly DependencyProperty ZoneProperty =
            RegisterProperty(
                "Zone",
                typeof(Zone),
                typeof(Hex),
                new PropertyMetadata(null));

        /// <summary>
        /// Defines the ResourceId Property.
        /// </summary>
        public static readonly DependencyProperty ResourceIdProperty =
            RegisterProperty(
                "ResourceId",
                typeof(int?),
                typeof(Hex),
                new PropertyMetadata(null));

        /// <summary>
        /// Defines the Resource Property.
        /// </summary>
        public static readonly DependencyProperty ResourceProperty =
            RegisterProperty(
                "Resource",
                typeof(Resource),
                typeof(Hex),
                new PropertyMetadata(null));

        /// <summary>
        /// Defines the X Property.
        /// </summary>
        public static readonly DependencyProperty XProperty =
            RegisterProperty(
                "X",
                typeof(double),
                typeof(Hex),
                new PropertyMetadata(-1));

        /// <summary>
        /// Defines the Y Property.
        /// </summary>
        public static readonly DependencyProperty YProperty =
            RegisterProperty(
                "Y",
                typeof(double),
                typeof(Hex),
                new PropertyMetadata(-1));

        /// <summary>
        /// Defines the Scale Property.
        /// </summary>
        public static readonly DependencyProperty ScaleProperty =
            RegisterProperty(
                "Scale",
                typeof(double),
                typeof(Hex),
                new PropertyMetadata(-1));


        /// <summary>
        /// Gets or sets the Id of this Hex.
        /// </summary>
        
        public int Id
        {
            get { return (int)SafeGetValue(IdProperty); }
            set { SafeSetValue(IdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Number of this Hex.
        /// </summary>
        
        public int Number
        {
            get { return (int)SafeGetValue(NumberProperty); }
            set { SafeSetValue(NumberProperty, value); }
        }

        /// <summary>
        /// Gets or sets the TimeSpan that this Hex is locked down for.
        /// </summary>
        
        public TimeSpan LockedDown
        {
            get { return (TimeSpan)SafeGetValue(LockedDownProperty); }
            set { SafeSetValue(LockedDownProperty, value); }
        }

        /// <summary>
        /// Gets or sets the OwnerId.
        /// </summary>
        
        public int? OwnerId
        {
            get { return (int?)SafeGetValue(OwnerIdProperty); }
            set { SafeSetValue(OwnerIdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Owner.
        /// </summary>
        
        public Agency Owner
        {
            get { return (Agency)SafeGetValue(OwnerProperty); }
            set { SafeSetValue(OwnerProperty, value); }
        }

        /// <summary>
        /// Gets or sets the FacilityId.
        /// </summary>
        
        public int? FacilityId
        {
            get { return (int?)SafeGetValue(FacilityIdProperty); }
            set { SafeSetValue(FacilityIdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Facility.
        /// </summary>
        
        public Facility Facility
        {
            get { return (Facility)SafeGetValue(FacilityProperty); }
            set { SafeSetValue(FacilityProperty, value); }
        }

        /// <summary>
        /// Gets or sets if this hex is shielded.
        /// </summary>
        
        public bool IsShielded
        {
            get { return (bool)SafeGetValue(IsShieldedProperty); }
            set { SafeSetValue(IsShieldedProperty, value); }
        }

        /// <summary>
        /// Gets or sets the hex id of the shield base that shields this hex.
        /// </summary>
        
        public int? ShieldBaseId
        {
            get { return (int?)SafeGetValue(ShieldBaseIdProperty); }
            set { SafeSetValue(ShieldBaseIdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Hex that shields this hex.
        /// </summary>
        
        public Hex ShieldBase
        {
            get { return (Hex)SafeGetValue(ShieldBaseProperty); }
            set { SafeSetValue(ShieldBaseProperty, value); }
        }

        /// <summary>
        /// Gets or sets if this hex is a base or not.
        /// </summary>
        
        public bool IsBase
        {
            get { return (bool)SafeGetValue(IsBaseProperty); }
            set { SafeSetValue(IsBaseProperty, value); }
        }

        /// <summary>
        /// Gets or sets the ZoneId this hex is located in.
        /// </summary>
        
        public int ZoneId
        {
            get { return (int)SafeGetValue(ZoneIdProperty); }
            set { SafeSetValue(ZoneIdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Zone this Hex is located in.
        /// </summary>
        
        public Zone Zone
        {
            get { return (Zone)SafeGetValue(ZoneProperty); }
            set { SafeSetValue(ZoneProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Resource Id this Hex has.
        /// </summary>
        
        public int? ResourceId
        {
            get { return (int?)SafeGetValue(ResourceIdProperty); }
            set { SafeSetValue(ResourceIdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Resource this Hex has.
        /// </summary>
        
        public Resource Resource
        {
            get { return (Resource)SafeGetValue(ResourceProperty); }
            set { SafeSetValue(ResourceProperty, value); }
        }

        /// <summary>
        /// Gets or sets the X location on the map this hex is.
        /// </summary>
        
        public double X
        {
            get { return (double)SafeGetValue(XProperty); }
            set { SafeSetValue(XProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Y location on the map this hex is.
        /// </summary>
        
        public double Y
        {
            get { return (double)SafeGetValue(YProperty); }
            set { SafeSetValue(YProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Visual Scale of the Hex.
        /// </summary>
        
        public double Scale
        {
            get { return (double)SafeGetValue(ScaleProperty); }
            set { SafeSetValue(ScaleProperty, value); }
        }

        public Hex()
        {
        }

        public Hex(LinkedDependencyObject baseObject)
            : base(baseObject)
        {
        }

        public Hex(LinkedDependencyObject baseObject, BindingMode bindingMode)
            : base(baseObject, bindingMode)
        {
        }
    }
}
